fix: skip reasoningContent blocks in LlamaAPI, llama.cpp, and Writer models#2072
Open
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Open
Conversation
…models In multi-provider Swarms, reasoning-capable models (e.g. Gemini, Claude) store reasoningContent blocks in shared conversation history. When that history is passed to LlamaAPIModel, LlamaCppModel, or WriterModel, the content-type filter only skipped toolResult and toolUse blocks — not reasoningContent — causing a TypeError on the next turn. Extends the fix already applied to openai.py and openai_responses.py (PR strands-agents#2013) to the three remaining affected providers. Also removes reasoningContent from the unsupported-type parametrize in test_writer.py and adds a dedicated skip test to each model's test file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In multi-provider Swarms, reasoning-capable models (e.g. Gemini, Claude) store
reasoningContentblocks in shared conversation history. When that history ispassed to
LlamaAPIModel,LlamaCppModel, orWriterModelon a subsequent turn,the content-type filter only skipped
toolResultandtoolUseblocks — notreasoningContent— causingTypeError: content_type=<reasoningContent> | unsupported type.PR #2013 fixed this for
openai.pyandopenai_responses.py. This extends thesame fix to the three remaining affected providers by adding
"reasoningContent"to the skip list in each model's
_format_request_messages(and the visionformatter in
writer.py).Related Issues
Resolves #1993
Documentation PR
N/A
Type of Change
Bug fix
Testing
test_format_request_skips_reasoning_contentto each affected model's test filereasoningContentfromtest_writer.py'stest_format_request_with_unsupported_typeparametrize (it is no longer unsupported — it is silently skipped)hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.